package com.flot.yazb.model.user;

import com.flot.yazb.base.model.BModel;
import com.flot.yazb.base.client.RetrofitFactory;
import com.flot.yazb.aop.stub.RMCallback;
import com.flot.yazb.aop.stub.RMResponse;
import com.flot.yazb.retrofit.service.BService;

import java.util.Map;

public class CharacterModel extends BModel {
    public String tezheng;
    boolean isSelected=false;

    public String aihao;
    public static void geCharacter(String id,final Transit<CharacterModel[]> incubator) {
        RetrofitFactory.getInstance()
                .create(BService.UserService.class)
                .getCharacter(id)
                .enqueue(new RMCallback<RMResponse<CharacterModel[]>>(incubator.getContext()) {
                    @Override
                    protected void onSuccess(RMResponse<CharacterModel[]> result) {
                        incubator.onBorn(result.content, result.code(), result.message());
                    }

                    @Override
                    protected void onFail(String errorCode, String errorInfo) {
                        incubator.onBorn(null, errorCode, errorInfo);
                    }
                });
    }

    public static void setCharacter(Map<String ,String> map, final Transit<CharacterModel> incubator) {
        RetrofitFactory.getInstance()
                .create(BService.UserService.class)
                .setCharacter(map)
                .enqueue(new RMCallback<RMResponse<CharacterModel>>(incubator.getContext()) {
                    @Override
                    protected void onSuccess(RMResponse<CharacterModel> result) {
                        incubator.onBorn(result.content, result.code(), result.message());
                    }

                    @Override
                    protected void onFail(String errorCode, String errorInfo) {
                        incubator.onBorn(null, errorCode, errorInfo);
                    }
                });
    }

    public static void getHobby(String id,final Transit<CharacterModel[]> incubator) {
        RetrofitFactory.getInstance()
                .create(BService.UserService.class)
                .getHobby(id)
                .enqueue(new RMCallback<RMResponse<CharacterModel[]>>(incubator.getContext()) {
                    @Override
                    protected void onSuccess(RMResponse<CharacterModel[]> result) {
                        incubator.onBorn(result.content, result.code(), result.message());
                    }

                    @Override
                    protected void onFail(String errorCode, String errorInfo) {
                        incubator.onBorn(null, errorCode, errorInfo);
                    }
                });
    }

    public static void setHobby(Map map, final Transit<CharacterModel> incubator) {
        RetrofitFactory.getInstance()
                .create(BService.UserService.class)
                .setHobby(map)
                .enqueue(new RMCallback<RMResponse<CharacterModel>>(incubator.getContext()) {
                    @Override
                    protected void onSuccess(RMResponse<CharacterModel> result) {
                        incubator.onBorn(result.content, result.code(), result.message());
                    }

                    @Override
                    protected void onFail(String errorCode, String errorInfo) {
                        incubator.onBorn(null, errorCode, errorInfo);
                    }
                });
    }
}
